using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class BalloonShop : System.Web.UI.MasterPage
{
  // Website pages considered to be "catalog pages" that the visitor 
  // can "Continue Shopping" to
  private static string[] catalogPages = { "~/Default.aspx", "~/Catalog.aspx", "~/Search.aspx" };

  // Executes when any page based on this master page loads
  protected void Page_Load(object sender, EventArgs e)
  {
    // Don't perform any actions on postback events
    if (!IsPostBack)
    {
      /* Save the latest visited catalog page into the session
        to support "Continue Shopping" functionality */
      // Get the currently loaded page
      string currentLocation = Request.AppRelativeCurrentExecutionFilePath;
      // If the page is one of those we want the visitor to "continue shopping"
      // to, then save it to visitor's Session
      for (int i = 0; i < catalogPages.GetLength(0); i++)
        if (String.Compare(catalogPages[i], currentLocation, true) == 0)
        {
          // save the current location
          Session["LastVisitedCatalogPage"] = Request.Url.ToString();
          // stop the for loop from continuing
          break;
        }
    }
    if (Session["userName"] != null) 
    {
        lblUserName.Text = Session["userName"].ToString();
        lbLogin.Visible = false;
        lbSignUp.Visible = false;
        hello.Visible = true;
        lblUserName.Visible = true;
        lbLogout.Visible = true;
        lbEdit.Visible = true;
    }

  }
  
  protected void lbSignUp_Click(object sender, EventArgs e)
  {
      Response.Redirect("MemberRegistrationaspx.aspx");
  }
  protected void lbLogout_Click(object sender, EventArgs e)
  {
      Session["userName"] = null;
      
      lbLogin.Visible = true;
      lbSignUp.Visible = true;
      lbLogout.Visible = false;
      lbEdit.Visible = false;
      lblUserName.Visible = false;
      Session.Clear();
      Session.Abandon();
      Response.Redirect("Default.aspx");
  }
  protected void lbLogin_Click(object sender, EventArgs e)
  {
      Response.Redirect("Login.aspx");
  }
  protected void lbEdit_Click(object sender, EventArgs e)
  {
      if (Session["userName"] != null)
      {
          Response.Redirect("UpdateRegistration.aspx");
      }
      else
      {
          lbLogin.Visible = true;
          lbSignUp.Visible = true;
          lbLogout.Visible = false;
          lbEdit.Visible = false;
          lblUserName.Visible = false;
          Session.Clear();
          Session.Abandon();
          Response.Redirect("Oooops.aspx");
      }
  }
}

/*protected void hlLogout_Click(object sender, EventArgs e)
  {
      Session["userName"] = null;
      Response.Redirect("Oooops.aspx");

      hlLogin.Visible = true;
      hlSignUp.Visible = true;
      hlLogout.Visible = false;
      hlEditInfo.Visible=false;
  }*/